package com.zxbit.flash.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zxbit.flash.R;
import com.zxbit.flash.bean.HelpCenterData;

import java.util.List;

public class HelpCenterAdapter extends RecyclerView.Adapter<HelpCenterAdapter.HelpViewHolder> {

    private Context context;
    private List<HelpCenterData> data;

    public HelpCenterAdapter(Context context, List<HelpCenterData> data) {
        this.context = context;
        this.data = data;
    }

    @NonNull
    @Override
    public HelpViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_help_detail, viewGroup, false);
        return new HelpViewHolder(view);
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(@NonNull HelpViewHolder holder, int position) {
        holder.tvQuestion.setText("Q    " + data.get(position).getTitle());
        holder.tvAnswer.setText("A    " + data.get(position).getMessage());
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public class HelpViewHolder extends RecyclerView.ViewHolder {

        TextView tvQuestion;
        TextView tvAnswer;

        public HelpViewHolder(View itemView) {
            super(itemView);
            tvQuestion = itemView.findViewById(R.id.tv_question);
            tvAnswer = itemView.findViewById(R.id.tv_answer);
        }
    }
}
